Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hclsyntax: Pass marks through template expressions #404

Merged
merged 1 commit into from
Sep 24, 2020

Conversation

alisdair
Copy link
Contributor

If a template expression interpolates values which have marks, we should apply all of those marks to the output value. This allows template expressions to function like native cty functions with respect to marks.

If a template expression interpolates values which have marks, we should
apply all of those marks to the output value. This allows template
expressions to function like native cty functions with respect to marks.
@alisdair alisdair requested review from pselle and a team September 22, 2020 19:24
@alisdair alisdair self-assigned this Sep 22, 2020
Copy link
Contributor

@pselle pselle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

`hello%{ if false } ${target}%{ endif }`,
&hcl.EvalContext{
Variables: map[string]cty.Value{
"target": cty.StringVal("world").WithMarks(cty.NewValueMarks("sensitive")),
Copy link

@azr azr Sep 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Howdy ! I was looking at this and nice !!! We are probably going to use that for Packer too :D.

Question: can an object or a list be sensitive ? I couldn't tell from the test here ex:

variable "foo" {
  default = { 
    key = "secret"
    value = "secret"
  }
  sensitive = true
}

( maybe it would be worth it to tests that too if that should work )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's our hope, although it's very much work in progress. Applying marks to complex values currently doesn't work reliably, and this specific case (assuming your interpolation is like "key=${var.foo.key}") will currently panic.

I'll be opening a follow-up PR for that issue, and should be able to add an interpolation test case then. Thanks!

@alisdair alisdair merged commit 4997e11 into hcl2 Sep 24, 2020
@alisdair alisdair deleted the alisdair/pass-marks-through-expression-templates branch September 24, 2020 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants